import 'babel-polyfill';

import Vue from 'vue';

import Element from 'element-ui';

import './styles/index.scss';

import App from './App';
import router from './router';
import store from './store';
import i18n from './lang';
import './router/watch';
import './utils/filter';
import './directive/focus';

Vue.use(Element);

Vue.prototype.$ApiMessages = (code, obj) => {
  let m = i18n.t(`api.${code}`);
  if (obj) {
    Object.keys(obj).forEach((v) => {
      m = m.replace(new RegExp(`'\\.\\$${v}.'`, 'g'), obj[v]);
    });
  }
  return m;
};

Vue.config.productionTip = false;

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  store,
  i18n,
  components: { App },
  template: '<App/>',
});
